const Service = require('egg').Service;

var amqp = require('amqplib');

class RabbitMQ {


    async change(id,param){
        const {app,ctx,service} = this;
        //开启事务
        let t = await ctx.model.transaction();
        try {
            let rs = await ctx.model.FdOrder.findOne({where: {id},transaction:t,lock:t.LOCK.UPDATE});

            rs = {
                ...rs,
                ...param
            }

            await rs.save({transaction:t});
            t.commit();
        }catch (e) {
            //失败回滚
            t.rollback();
            //抛出错误信息
            ctx.throw(500,e.message)
        }
        return true;
    }

}

module.exports = RabbitMQ;
